package demo.java.lang.management.jvm;

import com.alibaba.fastjson.JSON;
import demo.java.lang.management.vo.DynamicJvmModel;
import demo.java.lang.management.vo.JVMThreadInfo;

import java.util.ArrayList;
import java.util.List;

/**
 * @author buffoon
 * @date 16/1/19
 */
public class ThreadEsUtil {

    public static List<String> getThreadInfos(DynamicJvmModel model) {

        List<String> result = new ArrayList<String>();
        List<JVMThreadInfo> threadInfos = model.getThreadInfos();
        if (threadInfos != null && threadInfos.size() > 0) {
            for (JVMThreadInfo info : threadInfos) {
                info.setAppName(model.getAppName());
                info.setHostname(model.getHostname());
                info.setTimestamp(model.getTimestamp());
                result.add(JSON.toJSONString(info));
            }
        }

        return result;
    }
}
